﻿namespace NetFx.SMIL
{
  using System;
  using System.Text;
  using System.Reflection;
  using System.Reflection.Emit;
  using System.Collections;
  using System.Collections.Generic;
  using NetFx.SMIL.Definitions;
  using NetFx.SMIL.References;

  /// <summary>
  /// Smil 操作数
  /// </summary>
  public class SmilOperand
  {
    #region Shortcuts
    public static SmilOperand it()
    {
      return new SmilOperand();
    }
    public static SmilOperand of(Reference valueRef)
    {
      return new SmilOperand(valueRef);
    }
    public static SmilOperand of(object valueRef)
    {
      return new SmilOperand(Reference.of(valueRef));
    }
    #endregion
    #region Fields
    protected Reference valueRef = null;
    protected bool? stackSigned = false;
    protected bool? checking = null;
    #endregion
    #region Properties
    public virtual bool? StackSigned
    {
      get
      {
        return this.stackSigned;
      }
      set
      {
        this.stackSigned = value;
      }
    }
    public virtual bool? Checking
    {
      get
      {
        return this.stackSigned;
      }
      set
      {
        this.stackSigned = value;
      }
    }
    public virtual bool HasValueRef
    {
      get
      {
        return this.valueRef!=null;
      }
    }
    public virtual Reference ValueRef
    {
      get
      {
        return this.valueRef;
      }
      set
      {
        this.valueRef = value;
      }
    }
    #endregion
    #region Constructors
    public SmilOperand() : this(Reference.it()) { }
    public SmilOperand(Reference valueRef)
      : this(valueRef, null, null)
    {
    }
    public SmilOperand(Reference valueRef, bool? stackSign, bool? checking)
    {
      this.valueRef = valueRef;
      this.stackSigned = stackSign;
      this.checking = checking;
    }
    #endregion
    #region Methods
    public override string ToString()
    {
      return this.HasValueRef ? this.ValueRef.ToString() : string.Empty;
    }
    #endregion
  }
}
